/*
  gsap补间动画
  npm i gsap

  gsap属性,运动,暂停
*/
import gsap from gsap
gsap.to(cube.position, {x:5,duration:5,ease:"power1.in"})


let animate = gsap.to(cube.rotation, {
  x: Math.PI * 2,
  duration: 5,
  ease: "power1.inOut",
  //设置重复次数,无限循环-1
  repeat: 2,
  //往返运动
  yoyo: true,
  //延迟时间
  delay: 2,
  onComplete: ()=>{
    console.log('动画完成')
  },
  onStart: ()=>{
    console.log('动画开始')
  }
})

//监听双击事件
window.addEventListener('dblclick',()=>{
  if(animate.isActive()){
    //暂停
    animate.pause()
  }else{
    //恢复
    animate.resume()
  }
})